<?php
namespace App\Services\Fund;
use App\Services\Fund\CurrencySplitLog\CurrencySplitLogLogic;
/**
 * 数字币冻结日志
 * Class CurrencySplitLog
 * @package App\Services\Fund
 */
class CurrencySplitLog
{
     //封装一层检验user_info、opposite_info后再执行stepRun <该页多数方法都需检验这两个json数据>
    /*protected function _checkJsonThenRun(array $data, string $method, string $scene = ''): array 
    {
        if(isset($data['user_info']) && $data['user_info'] !== '{}'){ $data['user_info'] = json_encode($data['user_info']); }
        if(isset($data['opposite_info']) && $data['opposite_info'] !== '{}'){ $data['opposite_info'] = json_encode($data['opposite_info']); }

        return $this->stepRun($data, $method, $scene);
    }*/

    /*数字币拆分*/
   /* public function split(): array 
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'currency'=>'0', 'lock_key'=>'', 'get_key'=>'', 'update_ip'=>' ', 'app_id'=>' ', 'user_info'=>'{}','opposite_info'=>'{}']);
        return $this->_checkJsonThenRun($data, 'split', 'split');
    }*/

    /*交易方锁定亚数币*/
   /* public function lock(): array 
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'public_key'=>' ', 'lock_key'=>' ', 'update_ip'=>' ', 'app_id'=>' ', 'user_info'=>'{}','opposite_info'=>'{}']);
        return $this->_checkJsonThenRun($data, 'lock', 'lock');
    }*/

    /*交易方读取锁定的亚数币*/
   /* public function readLock(): array 
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'public_key'=>' ', 'get_key'=>' ', 'update_ip'=>' ', 'app_id'=>' ', 'user_info'=>'{}','opposite_info'=>'{}']);
        $data['is_lock'] = 1;
        return $this->_checkJsonThenRun($data, 'read', 'readLock');
    }*/

    /*交易方直接读取亚数币*/
  /*  public function read(): array 
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'public_key'=>' ', 'get_key'=>' ', 'update_ip'=>' ', 'app_id'=>' ', 'user_info'=>'{}','opposite_info'=>'{}']);
        $data['is_lock'] = 0;
        return $this->_checkJsonThenRun($data, 'read', 'read');
    }*/

    /*冻结亚数币*/
   /* public function freeze(): array
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'opposite_id'=>'0', 'currency'=>'0', 'update_ip'=>' ', 'app_id'=>'0', 'user_info'=>'{}','opposite_info'=>'{}']);
        return $this->_checkJsonThenRun($data, 'freeze', 'freeze');
    }*/

    /*解冻亚数币*/
   /* public function unfreeze(): array
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'opposite_id'=>'0', 'currency'=>'0', 'update_ip'=>' ', 'app_id'=>'0', 'freeze_log_id'=>'0', 'user_info'=>'{}','opposite_info'=>'{}']);
        return $this->_checkJsonThenRun($data, 'unfreeze', 'unfreeze');
    }*/

    /*获取数字币拆分记录*/
    public function list($data): array 
    {
         $data = init_array($data,['page'=>'1', 'list_rows'=>'']);
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        return (new CurrencySplitLogLogic())->list($data);
    }

    //获取指定用户的数字币拆分记录
    public function listByUserIds($data): array
    {
         $data = init_array($data,['page'=>'1', 'list_rows'=>'', 'user_ids'=>' ']);
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        ValidateCurrencySplitLog::checkValidate($data, ['page', 'list_rows','user_ids']);
        return (new CurrencySplitLogLogic())->listByUserIds($data);
    }

    /*获取某个用户的某个状态下的列表*/
    public function listByUserStatus($data): array
    {
         $data = init_array($data,['user_id'=>'0', 'status'=>' ', 'page'=>'1', 'list_rows'=>'']);
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        ValidateCurrencySplitLog::checkValidate($data, ['page', 'list_rows','user_id','status']);
        return (new CurrencySplitLogLogic())->listByUserStatus($data);
    }

}